import { XMLExporter } from './XMLExporter'
import { FCPXMLDExporter } from './FCPXMLDExporter'

const fileInfo = {
  base: '%E4%BD%A0%E5%B9%B2%E5%98%9B.mp4',
  name: '%E4%BD%A0%E5%B9%B2%E5%98%9B',
  ext: '.mp4',
  size: 13870189,
  type: 'video/mp4',
}
// mediaInfo中的信息均可通过ffmpeg获取
const mediaInfo = {
  frameCount: 814,
  frameRate: 24,
  duration: 33.916667,
  width: 1920,
  height: 1080,
  isRotated: false,
  orientation: 'landscape',
  audioCodec: 'aac',
  audioExt: '.aac',
  channelCount: 2,
  sampleRate: 48000,
  bitRate: 3075351,
  depth: 16,
  ntsc: false,
  fieldOrder: 'progressive',
  durationTs: 416768,
  timeBase: 12288,
  frameDuration: 512,
}
// 保留的片段[开始,结束]
const fragmentArray = [
  [0, 0.115],
  [2.3306199999999997, 3.1654],
  [3.456, 5.08373],
  [7.304749999999999, 7.8375],
  [8.72658, 9.97706],
  [11.273299999999999, 13.3262],
  [14.3426, 15.6556],
  [15.8268, 23.484499999999997],
  [24.035600000000002, 25.6661],
  [26.9368, 27.2748],
  [28.4886, 31.866999999999997],
  [33.091699999999996, 33.92],
]

async function main() {
  const fcpxmldExporter = new FCPXMLDExporter(
    fileInfo,
    mediaInfo,
    fragmentArray
  )
  await fcpxmldExporter.download()

  const xmlExporter = new XMLExporter(fileInfo, mediaInfo, fragmentArray)
  await xmlExporter.download()
}

main()

document.getElementById('text').innerText = 'XML生成完毕，请打开浏览器控制台'
